/*******************************************************************************
** www.IfcGears.com                                                           **
** Copyright (C) 2010 - Bauhaus University Weimar, www.uni-weimar.de          **
** Written: 2010-10-02, Fabian Gerold, www.fabiangerold.de                    **
*******************************************************************************/

#pragma once

#include <QtGui>
#include "shared_ptr.h"

class Type;
class Entity;
class SelectType;

class IfcRelease
{
public:
	std::map<QString,shared_ptr<Type> >		m_map_types;
	std::map<QString,shared_ptr<Entity> >	m_map_entities;
};

class IfcGears : public QObject
{
	Q_OBJECT

public:
	static const bool SELECT_DERIVE = true;

	IfcGears();

	void parseSchemaFiles( QStringList content_in );
	void parseSchema( QString content );
	void processTypesAndEntities();
	void setPathOut( QString path_out );
	
	bool parseTypeFirst( shared_ptr<Type> t );
	bool parseEntityFirst( shared_ptr<Entity> e );
	bool parseTypeSecond( shared_ptr<Type> t );
	bool parseEntitySecond( shared_ptr<Entity> e );
	
	bool findTypes( QString& file_content, int complete_size, QString schema_version );
	bool findEntities( QString& file_content, int complete_size, QString schema_version );
	bool findFunctions( QString& file_content, int complete_size, QString schema_version );
		
	bool writeIfcClassFiles();
	void writeCMakeFile();
	void writeReaderEntities();
	void writeFile( QString path, QString& content );
	
	std::map<QString,QString>			m_basic_types; // express type -> cpp type
	QString								m_header_comment;
	
	//std::map<QString,shared_ptr<IfcRelease> >		m_ifc_releases;
	shared_ptr<IfcRelease>				m_ifc_release;
	bool								m_ifc_namespace;
	bool								m_method_setEntity;
	bool								m_include_comments;
	
signals:
	void signalTxtOut( QString out );
	void signalTxtOutWarning( QString out );
	void signalProgressValue( int );

public slots:
	void slotEmitTxtOut( QString txt );
	void slotEmitTxtOutWarning( QString txt );

private:
	std::map<QString,QString>			m_additional_parser;
	QString								m_filename_chars;
	QString								m_path_out;
};
